package com.itheima.controller;

import com.itheima.dto.MediaUserDto;
import com.itheima.po.MediaUser;
import com.itheima.po.User;
import com.itheima.service.UserService;
import com.itheima.vo.MediaUserVo;
import com.itheima.vo.Result;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author :wujunjie
 * createTime :2023-01-02 16:53
 * description :
 */
@RestController
@RequestMapping("/login")
public class LoginController {
    @Autowired
    private UserService userService;

    @PostMapping("/in")
    public Result login(@RequestBody MediaUserDto dto){
        MediaUserVo login=userService.login(dto);
        if (ObjectUtils.isEmpty(login)){
            return Result.error();
        }
        return Result.success(login);
    }
}
